package com.itheima.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
/*开启切面*/
@Aspect
public class AOPAdvice {
    /*配置切点*/
@Pointcut("execution(* *..*(..))")
public void pt(){}

//配置前置通知
    @Before("pt()")
    public void before(){
        System.out.println("前置before...");
    }

    @After("pt()")
    public void after(){
        System.out.println("后置after...");
    }

    @AfterReturning("pt()")
    public void afterReturing(){
        System.out.println("返回后afterReturing...");
    }

    @AfterThrowing("pt()")
    public void afterThrowing(){
        System.out.println("抛出异常后afterThrowing...");
    }

    @Around("pt()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("环绕前around before...");
        Object ret = pjp.proceed();
        System.out.println("环绕后around after...");
        return ret;
    }


   /* public void aop002log(){
        System.out.println("前置before...1");
    }*/

//    @Before("AOPPointcut.pt1()")
//    public void aop002exception(){
//        System.out.println("前置before...2");
//    }

}